﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Motoball.screenmanager;

namespace Motoball.screens
{
    /// <summary>
    /// inherits from GameScreen because of simple management by
    /// screenManager
    /// </summary>
    public class CameraMovementScreen : GameScreen
    {
        Matrix source;
        Matrix destination;
        int timer;
        
        public CameraMovementScreen(string screenName)
            : base(screenName)
        {
        }

        public override void Draw(GameTime gameTime)
        {

        }
        public override void Update(GameTime gameTime)
        {
            timer += gameTime.ElapsedGameTime.Milliseconds;
            float seconds = timer / 1000f;

            if (seconds >= 1.5f)
            {
                seconds = 1.5f;
                Exit();
            }
            Motoball.camera.view = Matrix.Lerp(source, destination, seconds / 1.5f);
        }

        public override void LoadContent()
        {            
        }
        

        public void StartCameraMovement(Matrix source, Matrix destination)
        {
            timer = 750;
            this.source = source;
            this.destination = destination;
        }

        protected override void Exit()
        {
            screenManager.RemoveScreen(this);
        }
    }
}
